﻿''
''Copyright Zac McKenzie 2012
''

Imports smtp = System.Net.Mail
Public Class email

    Public Shared Sub sendEmail(ByVal from As String, ByVal [to] As String, ByVal subject As String, ByVal body As String)
        If config.serverHost = "" Then Exit Sub
        'create the mail message
        Dim mail As New smtp.MailMessage()

        'set the addresses
        mail.From = New smtp.MailAddress(from)
        mail.[To].Add([to])

        'set the content
        mail.Subject = subject
        mail.Body = body

        'set the server
        Dim smtp As New smtp.SmtpClient(config.serverHost, config.serverPort)

        smtp.EnableSsl = True
        smtp.Credentials = New System.Net.NetworkCredential(config.emailUserId, config.emailPassword)

        'send the message
        Try
            smtp.Send(mail)
        Catch exc As Exception
            MsgBox("Send failure: " & exc.ToString())
        End Try
    End Sub

End Class
